/**
 * 
 */

/**
 * @author Zuwa
 *
 */
public class Modulus extends Operator {
	/**
     * Return the number of arguments this operator takes
     */
    public int nArguments() {
    	return 2;
    }
    
    /**
     * Evaluate this operator on the given expression
     */
    public Data evaluate(Data args[]) throws TypeException {
    	
    	//checking if the first operand is a number
    	if (!(args[0] instanceof NumberData)) {
    		throw new TypeException(getClass().getName()
    				+ ": first argument is not a number");
    	}
    	//checking if the second operand is a number
    	if (!(args[1] instanceof NumberData)) {
    		throw new TypeException(getClass().getName()
    				+ ": second argument is not a number");
    	}
    	
    	return new NumberData(((NumberData)args[0]).value % ((NumberData)args[1]).value);
    
    
    }
    
   
  

    /**
     * Return a string representation of this operator
     */
    public String toString() {
	return "%";
    }

}
